﻿<Application x:Class="WindowPlace.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:sw ="clr-namespace:System.Windows;assembly=PresentationFramework"
             xmlns:local="clr-namespace:WindowPlace"
             StartupUri="MainWindow.xaml">
    <Application.Resources>
        <BooleanToVisibilityConverter x:Key="BoolToVisibility"></BooleanToVisibilityConverter>


        <Style TargetType="TextBlock">
            <Setter Property="FontFamily" Value="Calibri"></Setter>
        </Style>
        <Style TargetType="TextBox">
            <Setter Property="FontFamily" Value="Calibri"></Setter>
        </Style>


        <!--Brushes etc-->
        <LinearGradientBrush StartPoint="0,0" EndPoint="0,1" x:Key="ToolTipGradient">
            <GradientStop Color="LightGray" Offset="0.6"></GradientStop>
            <GradientStop Color="DarkGray" Offset="1"></GradientStop>
        </LinearGradientBrush>

        <LinearGradientBrush StartPoint="0,0" EndPoint="0,1" x:Key="Gradient1">
            <GradientStop Color="RoyalBlue" Offset="0.6"></GradientStop>
            <GradientStop Color="LightGray" Offset="1"></GradientStop>
        </LinearGradientBrush>

        <!--ToolTip-->
        <Style TargetType="ToolTip">
            <Setter Property="Foreground" Value="Black"></Setter>
            <Setter Property="BorderBrush" Value="Gray"></Setter>
            <Setter Property="BorderThickness" Value="1"></Setter>
            <Setter Property="Padding" Value="5"></Setter>
            <Setter Property="Background" Value="{StaticResource ToolTipGradient}"></Setter>
        </Style>

        <DataTemplate x:Key="WindowInfoTemplate">
            <Grid Margin="1">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition></ColumnDefinition>
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition></RowDefinition>
                    <RowDefinition></RowDefinition>
                </Grid.RowDefinitions>
                <TextBlock Text="{Binding Caption}" FontSize="12" FontWeight="Bold" Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="2"
                           MaxWidth="380" TextWrapping="Wrap" HorizontalAlignment="Left"></TextBlock>
                <TextBlock Text="{Binding ModuleFilename, StringFormat='ModuleFilename: {0}'}" FontStyle="Italic"
                           MaxWidth="380" TextWrapping="Wrap"
                           Grid.Column="0" Grid.Row="3"></TextBlock>

            </Grid>
        </DataTemplate>

        <DataTemplate x:Key="DesiredWindowInfoTemplate">
            <Grid Margin="1">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition></ColumnDefinition>
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition></RowDefinition>
                    <RowDefinition></RowDefinition>
                    <RowDefinition></RowDefinition>
                    <RowDefinition></RowDefinition>
                    <RowDefinition></RowDefinition>
                </Grid.RowDefinitions>
                <StackPanel Orientation="Horizontal" Grid.Column="0" Grid.Row="0" >
                    <Image HorizontalAlignment="Right" VerticalAlignment="Center" Width="13"
                            Visibility="{Binding IsFound, Converter={StaticResource BoolToVisibility}}" 
                            Source="/WindowPlace;component/icons/ball_green.png" ></Image>
                    <Image HorizontalAlignment="Right" VerticalAlignment="Center" Width="13"
                            Visibility="{Binding IsNotFound, Converter={StaticResource BoolToVisibility}}" 
                            Source="/WindowPlace;component/icons/ball_red.png" ></Image>
                    <TextBlock Text="{Binding Caption}" FontSize="12" FontWeight="Bold" 
                           MaxWidth="300" TextWrapping="Wrap" HorizontalAlignment="Left"
                               VerticalAlignment="Center" Margin="5,1"></TextBlock>
                </StackPanel>
                <WrapPanel Orientation="Horizontal" Grid.Column="0" Grid.Row="1" MaxWidth="300" HorizontalAlignment="Left">
                    <TextBlock Text="{Binding CaptionFilter, StringFormat='CaptionFilter: {0}'}" 
                               FontWeight="Bold" Margin="2,1"></TextBlock>
                    <TextBlock Text="{Binding ModuleFilename, StringFormat='ModuleFilename: {0}'}" FontStyle="Italic"
                               Margin="1" ></TextBlock>
                </WrapPanel>
                <!--<StackPanel Orientation="Horizontal" Grid.Column="0" Grid.Row="2">
                    <TextBlock Text="{Binding LocationString}" Margin="2,1"></TextBlock>
                    <TextBlock Text="{Binding SizeString}" Margin="8,1"></TextBlock>
                </StackPanel>-->

                <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Bottom">
                    <StackPanel.Resources>
                        <Style TargetType="Button">
                            <Setter Property="Background" Value="RoyalBlue"></Setter>
                        </Style>
                    </StackPanel.Resources>
                    <Button Command="{x:Static local:MainWindow.RemoveWindowInfoCommand}"
                        CommandParameter="{Binding }"
                        ToolTip="Remove this WindowInfo from all Profiles">
                        <StackPanel Orientation="Horizontal">
                            <Image Source="/WindowPlace;component/icons/bt_delete.png" Height="12"></Image>
                            <!--<TextBlock Text="Remove" VerticalAlignment="Center" FontWeight="Bold" Margin="5,2"></TextBlock>-->
                        </StackPanel>
                    </Button>
                    <Button Command="{x:Static local:MainWindow.EditWindowInfoCommand}"
                        CommandParameter="{Binding }"
                        ToolTip="Edit this WindowInfo">
                        <StackPanel Orientation="Horizontal">
                            <Image Source="/WindowPlace;component/icons/settings.png" Height="12"></Image>
                            <!--<TextBlock Text="Edit" VerticalAlignment="Center" FontWeight="Bold" Margin="5,2"></TextBlock>-->
                        </StackPanel>
                    </Button>
                    <Button Command="{x:Static local:MainWindow.SetToCurrentPositionCommand}"
                        CommandParameter="{Binding }"
                        ToolTip="Set to the Current Window Position &amp; Size">
                        <StackPanel Orientation="Horizontal">
                            <Image Source="/WindowPlace;component/icons/computer.png" Height="12"></Image>
                            <!--<TextBlock Text="Remove" VerticalAlignment="Center" FontWeight="Bold" Margin="5,2"></TextBlock>-->
                        </StackPanel>
                    </Button>
                </StackPanel>
            </Grid>
        </DataTemplate>

        <DataTemplate x:Key="PlaceProfileTemplate">
            <Grid Height="40" Margin="1">
                <TextBlock Text="{Binding Label}" TextWrapping="Wrap" MaxWidth="120" MinWidth="80"
                           FontSize="14"
                           FontWeight="Bold" HorizontalAlignment="Center" TextAlignment="Center"
                           VerticalAlignment="Top"></TextBlock>
                <TextBlock FontStyle="Italic"
                           FontSize="8"
                           VerticalAlignment="Bottom"
                           HorizontalAlignment="Right"
                           TextAlignment="Right">
                    <TextBlock.Text>
                        <MultiBinding StringFormat="{}{0}+{1}" FallbackValue="Bob">
                            <Binding Path="HotKeyCombinationString" RelativeSource="{RelativeSource AncestorType=Window}"></Binding>
                            <Binding Path="Index"></Binding>
                            <!--<Binding Path="Label"></Binding>-->
                        </MultiBinding>
                    </TextBlock.Text>
                </TextBlock>
                <Button HorizontalAlignment="Left" VerticalAlignment="Bottom" Grid.RowSpan="99"
                        Command="Refresh" Background="Transparent"
                        CommandParameter="{Binding }"
                        ToolTip="Apply this Profile">
                    <StackPanel Orientation="Horizontal">
                        <Image Source="/WindowPlace;component/icons/quick_restart.png" Height="12"></Image>
                    </StackPanel>
                </Button>
            </Grid>
        </DataTemplate>

        <Style x:Key="ContainerStyle" TargetType="ListBoxItem">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="ListBoxItem">
                        <Border CornerRadius="3" BorderBrush="RoyalBlue" BorderThickness="2" Margin="1" Padding="1"
                                x:Name="Bd">
                            <Border.Background>
                                <SolidColorBrush Color="LightSteelBlue" x:Name="Bk" Opacity="0.7"></SolidColorBrush>
                            </Border.Background>
                            <sw:VisualStateManager.VisualStateGroups>
                                <sw:VisualStateGroup Name="CommonStates">
                                    <!--<sw:VisualState Name="Normal">
                                        <Storyboard>
                                            <DoubleAnimation Storyboard.TargetName="Bd" 
                                                             Storyboard.TargetProperty="Opacity" 
                                                             To="0.3" 
                                                             Duration="0:0:0.2"></DoubleAnimation>
                                        </Storyboard>
                                    </sw:VisualState>
                                    <sw:VisualState x:Name="MouseOver">
                                        <Storyboard>
                                            <DoubleAnimation Storyboard.TargetName="Bd" 
                                                             Storyboard.TargetProperty="Opacity" 
                                                             To="1" 
                                                             Duration="0:0:0.2"></DoubleAnimation>
                                        </Storyboard>
                                    </sw:VisualState>-->
                                </sw:VisualStateGroup>
                                <sw:VisualStateGroup Name="SelectionStates">
                                    <sw:VisualState Name="Selected">
                                        <Storyboard>
                                            <ColorAnimation To="Orange" Storyboard.TargetName="Bk" Storyboard.TargetProperty="Color" 
                                                            Duration="0:0:0.2"></ColorAnimation>
                                        </Storyboard>
                                    </sw:VisualState>
                                    <sw:VisualState Name="Unselected">
                                        <Storyboard>
                                            <ColorAnimation To="LightSteelBlue" Storyboard.TargetName="Bk" Storyboard.TargetProperty="Color" 
                                                            Duration="0:0:0.2"></ColorAnimation>
                                        </Storyboard>
                                    </sw:VisualState>
                                </sw:VisualStateGroup>
                            </sw:VisualStateManager.VisualStateGroups>

                            <ContentPresenter VerticalAlignment="Center"></ContentPresenter>
                        </Border>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </Application.Resources>
</Application>
